package com.qqtech.qquan.user.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.qquan.user.model.*;

@Repository
public class UserAuthDaoImpl extends BaseDaoImpl<UserAuth> implements UserAuthDao {
	public static final Logger log = LoggerFactory.getLogger(UserAuthDaoImpl.class);
	
	public UserAuthVo getByUserId(java.lang.Integer userId) {
		return sqlSessionTemplate.selectOne(getSqlName("selectByUserId"), userId);
	}	
	
	@Override
	public int queryCountAdmin(UserAuthQuery query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectCountAdmin"), BeanUtil.toMap(query));
	}
	
	@Override
	public Page<UserAuthVo> queryPageListAdmin(UserAuthQuery query,
			Pageable pageable) {
		List<UserAuthVo> contentList = sqlSessionTemplate.selectList(getSqlName("selectAdmin"), getParams(query, pageable));
		return new PageImpl<UserAuthVo>(contentList, pageable, this.queryCountAdmin(query));
		
	}
}
